home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / STRSPN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  548 b   |  22 lines

  1. /* strspn.c  From TC Bible page 299  Use strspn to locate the position of the
  2. first character in a string that does not belong to the set of characters
  3. in another. */
  4.  
  5.  
  6.  
  7. #include <stdio.h>
  8. #include <string.h>
  9.  
  10. char *whitespace = " \t\n"; /* space, tab, and  new line are the
  11.                              whitespace characters */
  12. main()
  13. {
  14.     int loc;
  15.     char str1[80];
  16.     printf("Enter a string with preceding blanks: ");
  17.     gets(str1);
  18.     loc = strspn(str1, whitespace);
  19.     printf("First non-whitespace character in \n%s\nis at location %d\n",
  20.     str1, loc);
  21. }
  22.